﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using bdnt_pets_system_Entity;
using System.Globalization;
using System.IO.IsolatedStorage;

namespace bdnt_pets_system.Tools
{
    public static class SessionManager
    {
        public const string USERNAME = "username";
        public const string PASSWORD = "password";
        public const string SAVELOGINSTATE = "saveloginstate";
        public const string USERINFO = "userinfo";
        public const string ISCHINESE = "ischinese";
        //public static string qsr { get { return "请输入"; } }
        //public static string bnwk { get { return "不能为空"; } }
        //public static string qxz { get { return "请选择"; } }

        /// <summary>
        /// 权限内所有菜单
        /// </summary>
        public static ObservableCollection<Tbl_Menu> RoleAllMenus = new ObservableCollection<Tbl_Menu>();
        /// <summary>
        /// 所有菜单
        /// </summary>
        public static ObservableCollection<Tbl_Menu> AllMenus = new ObservableCollection<Tbl_Menu>();

        private static Dictionary<string, object> session = new Dictionary<string, object>();

        public static Dictionary<string, object> Session
        {
            get { return SessionManager.session; }
            set { SessionManager.session = value; }
        }
        public static int PageSize = 10;

        public static bool IsCN_ZH
        {
            get
            {
                return CultureInfo.CurrentCulture.Name == "en-US" ? false : true;
            }
        }

        public static Tbl_Employee CurrentUser
        {
            get
            {
                if (IsolatedStorageSettings.ApplicationSettings.Contains(SessionManager.USERINFO))
                {
                    var cuo = IsolatedStorageSettings.ApplicationSettings[SessionManager.USERINFO] as Tbl_Employee;
                    cuo.StationIds = (string.IsNullOrEmpty(cuo.StationIds) ? cuo.StationId.ToString() : (cuo.StationId > 0 ? (cuo.StationIds + "," + cuo.StationId.ToString()) : cuo.StationIds));
                    return cuo;
                }
                return new Tbl_Employee();
            }
        }

    }
}
